from tkinter.messagebox import showwarning

from commons.public_gobals import PublicGlobals
from mes.NewSaveBluetoothTestData import NewSaveBluetoothTestData
from windows import report_data, test_result_var


def MES_upload():
    try:
        flag = NewSaveBluetoothTestData(url=PublicGlobals.url,
                                 barCode=PublicGlobals.sn_Seq,
                                 BTTestData=str(report_data)[1:-1],
                                 TestResults=test_result_var.get(),
                                 stationID=PublicGlobals.stationID)
        return str(flag)
    except Exception as e:
        # print('上传数据失败',e)
        showwarning(message=f'上传数据失败{e}')
        return str(False)